#!/usr/bin/env python
# -*- coding: utf-8 -*-
import itertools

def listConcat(list):
    retVal=""
    for element in list:
        retVal=retVal+str(element)
    return retVal

lexiList=[]

count=0
for p in itertools.permutations('0123456789'):
    count +=1    
    #print p
    newElement=listConcat(p)
    #print newElement    
    lexiList.append(newElement)

    '''if len(lexiList)>2000000:
        lexiList=sorted(lexiList)
        redLexiList=[]
        for i in range(1000000):
            redLexiList.append(lexiList[i])
        lexiList=[]
        for i in range(1000000):
            lexiList.append(redLexiList[i])'''
print count 

lexiList=sorted(lexiList)

print "size LexiList",len(lexiList)  


print lexiList[999999]
#print lexiList[1000000]
#print lexiList[1000001]
 

